package com.maven.user.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 * @Description: =======================
 * @Author: Jovi
 * =======================
 * @Date: Created in 2020/9/25
 * =======================
 * @Version: 0.0.1
 */
public class DbUtil {

    public static void main(String[] args) {
        System.out.println("DB");
    }

    private static Properties prop;

    static {
        prop = new Properties();
        try {
            prop.load(DbUtil.class.getResourceAsStream("/dbconf.properties"));
            String driver = prop.getProperty("driverClass");
            Class.forName(driver);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() {
        try {
            Connection conn = DriverManager.getConnection(prop.getProperty("url"), prop.getProperty("username"),
                    prop.getProperty("password"));
            return conn;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }


}
